package com.example.qxfw.dzzh.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.qxfw.common.entity.PotentialPoints;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
@DS("service")
public interface PotentialPointMapper extends BaseMapper<PotentialPoints> {

    @Select("select * " +
            "from potential_points " +
            "WHERE ( " +
            " 6371000 * acos ( " +
            " cos( radians( ${lat}))" +
            " * cos( radians( CAST(lat as numeric)))" +
            " * cos( radians( CAST(lon as numeric)) - radians( ${lon}))" +
            " + sin( radians( ${lat} ))" +
            " * sin( radians( CAST(lat as numeric)))" +
            ")) < ${distance} ")
    List<PotentialPoints> listByDistance(double lon,double lat,double distance);

    @Select("select distinct country "+
            "from potential_points " +
            "where country is not null and country !=''")
    List<String> selectCountry();

    @Select("select distinct dis_type "+
            "from potential_points " +
            "where dis_type is not null and dis_type !=''")
    List<String> selectDisType();


}
